﻿Chenxin.UI.AchievementDetail = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/AchievementDetail.ashx',
    createSearch: function() {
        return new Chenxin.UI.AchievementDetailSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.ReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'search_table',
            hasCheckBox: false,
            modelId: 'departid',
            autoLoad: false,
            height: 400,
            pageSize:100,
            hasPage:true,
            cellBorder: true,
            scope: this,
//			createTitleTool: function() {
//                return [{
//                    text: '<span class="simple">导出报表</span>',
//					scope:this,
//					title:'导出报表',
//					handler:function(el){
//						this.exportData();
//					}
//				}];
            //			},
            columns: {
                business: {
                    head: '商圈',
                    width: 100,
					captionCol:true
                },
                Depart: {
                    head: '门店',
                    width: 100,
                    sortable: true,
                    inTotal: false  
                },
				ContractCode: {
                    head: '成交编号',
                    width: 120,
                    sortable: true,
                    inTotal: false  
                },
				ContractDate: {
                    head: '成交日期',
                    width: 80,
                    sortable: true,
                    inTotal: false                  
                },
				Region: {
                    head: '区域',
                    width: 50,
                    sortable: true,
                    inTotal: false
                },
				HouseAddress: {
                    head: '房屋地址',
                    width: 120,
                    sortable: true,
                    inTotal: false
                },
				Employee: {
                    head: '业务员',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
			    DeparterManagerName: {
                    head: '店长',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
				MangerName: {
                    head: '高经',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                RegionManagerName: {
                    head: '区经',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                MajordomoName: {
                    head: '总监',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                AllCommision: {
                    head: '应收佣收',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                AllBeforeCommision: {
                    head: '折佣',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                AllConsulting: {
                    head: '咨询费',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                PureCommision: {
                    head: '业绩',
                    width: 80,
                    sortable: true
                },
                Point: {
                    head: '点数',
                    width: 40,
                    sortable: true
                },
                ApportionAR: {
                    head: '分摊应收',
                    width: 80,
                    sortable: true
                },
                ApportionConsulting: {
                    head: '分摊咨询费',
                    width: 80,
                    sortable: true
                },
                ApportionCommision: {
                    head: '分摊业绩',
                    width: 80,
                    sortable: true
                },
                ArchivementDate: {
                    head: '业绩归属日期',
                    width: 80,
                    sortable: true,
                    inTotal: false
                },
                BargainCompanyName: {
                    head: '合同归属公司',
                    width: 80,
                    sortable: true,
                    inTotal: false
                }
        }
    });
},
	initEvent: function() {
		var _this = this;
	},
	initComponent: function() {
		Chenxin.UI.AchievementDetail.superclass.initComponent.call(this);
	}
});

/**
*查询面板
*/
Chenxin.UI.AchievementDetailSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;
        $('#btn_search').click(function() {
            _this.scope.reloadGrid("",0);
        });
		$('.a-qucik-search').click(function() {
            var sm = _this.getParamJson();
            sm.quicktype = this.id;
            _this.scope.grid.reload(sm);
            $(".menu_list").hide(1, function() { $(this).parent(".tlBtn").removeClass("click") });
        });
		$("input[name='keyWord']").defText({
            deftxt: '地址/成交编号/小区名称'
        });

        var curdate = new Date();
        $('#starttime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-1');
        if (curdate.getMonth() + 1 == 12)
            $('#eTime').val(curdate.getFullYear() + 1 + '-1-1');
        else
            $('#eTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 2) + '-1');
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 65
        });
        var status = new Chenxin.UI.Combo({
            containerId: '#status',
            tbxWidth: 65,
            items: comboCommon.AchievementType
        });
		var type = new Chenxin.UI.Combo({
            containerId: '#type',
            tbxWidth: 60,
			initValue:10,
            items: comboCommon.AchievementStyle
        });
	    var structs = combl.comboList;
		structs.push(status);
		structs.push(type);
	    return structs;
    },
    initComponent: function() {
        Chenxin.UI.AchievementDetailSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var AchievementDetail = new Chenxin.UI.AchievementDetail();
});